package com.migu.contacts.main;

import static com.migu.contacts.net.Service.API;

import com.frank.libandroid.BaseActivity;
import com.frank.libandroid.BaseAdapter;
import com.frank.libandroid.DataStore;
import com.frank.libandroid.HttpCallback;
import com.frank.libandroid.Key;
import com.frank.libandroid.butterknife.BindAdapter;
import com.frank.libandroid.butterknife.OnClick;
import com.migu.contacts.R;
import com.migu.contacts.bean.MessageBean;
import com.migu.contacts.databinding.ActivityNoticeBinding;
import com.migu.contacts.databinding.ItemNoticeBinding;

public class NoticeActivity extends BaseActivity<ActivityNoticeBinding> {
    public static final Key<MessageBean.Message> MessageBeanKey = new Key<>();
    @BindAdapter(R.id.recyclerView)
    BaseAdapter<ItemNoticeBinding, MessageBean.Message> adapter = new BaseAdapter<ItemNoticeBinding, MessageBean.Message>() {
        @OnClick(R.id.goDetail)
        public void goDetail(ItemNoticeBinding binding, MessageBean.Message bean, int position) {
            DataStore.put(MessageBeanKey, bean);
            start(NoticeDetailActivity.class);
        }
    };

    @Override
    protected void initData() {
        super.initData();
        API.getMessage(1, 99999, 0).watch(this, new HttpCallback<MessageBean>() {
            @Override
            protected void onSuccess(MessageBean messageBean) {
                adapter.setData(messageBean.list);
            }
        });
    }
}